<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../static/layui/css/layui.css">
</head>
<body>
<div class="layui-container">
    <div class="layui-row">
        <form class="layui-form" lay-filter="form1">
            <div class="layui-form-item">
                <label for="account" class="layui-form-label">账号</label>
                <div class="layui-input-block">
                    <input placeholder="账号" class="layui-input" disabled name="account" id="account"
                           style="width: 90.65%;display: inline-block">
                    <button class="layui-btn" type="button" onclick="changePassword()">修改密码</button>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="name" class="layui-form-label">姓名</label>
                <div class="layui-input-block">
                    <input placeholder="姓名" class="layui-input" name="name" id="name">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="status" class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <select id="status" name="status">
                        <option value="离线">离线</option>
                        <option value="出诊">出诊</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="subject" class="layui-form-label">科室</label>
                <div class="layui-input-block">
                    <select id="subject" name="subject">

                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="workTime" class="layui-form-label">工作时间</label>
                <div class="layui-input-block">
                    <input placeholder="工作时间" class="layui-input" name="workTime" id="workTime">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="introduce" class="layui-form-label">简介</label>
                <div class="layui-input-block">
                    <input placeholder="简介" class="layui-input" name="introduce" id="introduce">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="remark" class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea placeholder="备注" class="layui-textarea" name="remark" id="remark"></textarea>
                </div>
            </div>
            <div class="layui-form-item" style="float: right;">
                <button class="layui-btn" type="button" onclick="updateInfo()">修改信息</button>
            </div>
        </form>
    </div>
</div>
</body>
<script type="text/javascript" src="../static/layui/layui.all.js"></script>
<script type="text/javascript" src="../static/config.js"></script>
<script type="text/javascript">
    const $ = layui.$;
    const layer = layui.layer;
    const form = layui.form;

    $.post({
        url: baseUrl + "/hospital-web/process/getAllSubject",
        async: false,
        success: function (res) {
            if (res.data != null) {
                for (const obj of res.data) {
                    $("#subject").append(new Option(obj.subjectName, obj.subjectId));
                }
            }
        }
    });

    $.post({
        url: baseUrl + "/hospital-doctor/doctor/info",
        headers: {
            "x-token": localStorage.getItem("x-token")
        },
        success: function (res) {
            if (res.data != null) {
                form.val("form1", res.data);
            }
        }
    });

    function updateInfo() {
        $.post({
            url: baseUrl + "/hospital-doctor/doctor/update",
            headers: {
                "x-token": localStorage.getItem("x-token")
            },
            data: form.val("form1"),
            success: function (res) {
                location.reload();
            }
        });
    }

    function changePassword() {
        parent.layer.open({
            type: 2,
            content: 'frame/changePassword.html',
            area: ['400px', '250px'],
            title: '修改密码'
        });
    }

</script>
</html>